#include("/common/layout/bootstrap_form_layout.html")
#@layout()

#define title()     
#(jxrb.message(actionName,"systemDuty"))
#end
#if(systemDuty.duty_id ??)
#modeltag({tagcode:"jxbrms_systemduty",term:"duty_id=?",id:systemDuty.duty_id})
#end
#define head()
<script>
  seajs.use(['jquery', 'jx_pinyin', 'jx_msgbox', "action_tree", "jac", "jx_check"], function ($, jxpy, msgbox, at)
  {
    $("#b_submit").on("click", function ()
    {
      if (!jxCheck.check()) {
        return false;
      }
      $("#group_id").val(getCheckedNodes());
      //console.log($("#group_id"));
      msgbox.confirm({url: "#(controllerKey)#(action)/"},
      function ()
      {
        msgbox.close();
        window.parent.refreshTree($("#parentId").val());
        clearForm();
      }, function ()
      {
        window.parent.refreshTree($("#parentId").val());
        if (msgbox.messageType != 2)
          returnInfo();
      });
    });
    function setOldDutyid()
    {
      $("#old_group_id").val(getCheckedNodes());
    }
    var action = '#(action)';
    $("#b_return").on("click", function () {
      if (action == 'added') {
        location.href = "#(backurl)";
      } else {
        returnInfo()
      }
    });

    function returnInfo()
    {
      var parentId = $("#parentId").val();
      if (parentId == "") {
        location.href = "#(controllerKey)1-1"
      } else {
        location.href = "#(controllerKey)2-" + parentId;
      }
    }

    function clearForm()
    {
      if (action == 'added')
      {
        $("#viewNum").val(parseInt($("#viewNum").val()) + 1);
        $("#dutyName").val("");
        $("#dutyCode").val("");
        ztreeObjct.checkAllNodes(false);
      }
    }


    jxpy({nameObject: "#dutyName", codeObject: "#dutyCode"});

    if (action == 'added') {
      at.setViewNum('#(systemDuty.duty_id ??)');
    }

    function changeDuty()
    {
      at.setViewNum($("#parentId").val());
    }

    window.changeDuty = changeDuty;
    window.setOldDutyid = setOldDutyid;
  });
</script>
#include("/common/layout/ztree_check_layout.html",treeDataUrl=jxwebpath.item+"duty/groupTreeData/"+(systemDuty.duty_id ??),treeLoadOkFunction="setOldDutyid();")

#end

#define bodyExt()
class="gray-bg"
#end

#define form()
#include("info.html")
#end

#define formAfter()
<center>
  #jx_button({value:"action.save",class:"btn btn-primary"})&nbsp;&nbsp;&nbsp;&nbsp;
  #jx_button({value:"action.return",id:"b_return",class:"btn btn-danger"})
</center>
#end